<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //   function Person(name, age) {
      //     this.name = name;
      //     this.age = age;
      //   }
      //   Person.num = 10;
      //   Person.fn = function () {
      //     console.log("fn");
      //   };
      //   let zhangsan = new Person("张三", 20);
      //   let lisi = new Person("李四", 25);
      //   console.log(Person.num);
      //   Person.fn();
      //   class Person {
      //     static num = 10;
      //     constructor(name, age) {
      //       this.name = name;
      //       this.age = age;
      //       Person.num++;
      //       this.num = 0;
      //       this.num++;
      //       //num++;
      //     }
      //   }
      //   let zhangsan = new Person("张三", 20);
      //   let lisi = new Person("李四", 25);
      //   console.log(Person.num);
      class Person {
        #weight = "100kg";
        constructor() {
          this.name = "张三";
          this.age = 20;
        }
        // 共有方法获取私有属性；
        getWeight() {
          console.log("体重是", this.#weight);
        }
      }

      let zhangnan = new Person();
      console.log(zhangnan.name);
      // console.log(zhangnan.#weight);
      zhangnan.getWeight();
    </script>
  </body>
</html>
